package cn.vivi.user.controller;

import cn.vivi.common.entity.User;
import cn.vivi.common.util.Result;
import cn.vivi.user.entity.vo.LoginVo;
import cn.vivi.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("users")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("login")
    public Result<User> login(@RequestBody LoginVo vo) {
        User user = userService.login(vo);
        return user == null ? Result.error("登陆失败, 用户信息错误"): Result.success(user);
    }

}
